home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Design It! 3D (IDG)
/
Design It! 3D.iso
/
setup
/
vutility.in_
/
vutility.bin
Wrap
Text File
|
1995-07-06
|
9KB
|
313 lines
'----------------------------------------------------------------
'- more specialized little functions to make our lives easier.
'- John Alspaugh 13OCT94
'- Copyright 1993-1994 Virtus Corporation. All Rights Reserved.
'-
'- Note that this must be included after MSDETECT.INC and SETUPAPI.INC
'-
'----------------------------------------------------------------
'simple utility include.
'' dialog number
CONST LOOKFORFILE_DLG = 6352
CONST NO_WIN_3_1_DLG = 410
CONST WRONG_CPU_DLG = 411
DECLARE SUB VMessageBox(msg$, title$)
DECLARE SUB VDbgMsgBox(msg$, title$)
DECLARE FUNCTION VMakePath (szDir$, szFile$) AS STRING
DECLARE SUB VMaximizeFrame
DECLARE FUNCTION VFindExeFromRegistration(pFExten$, pDest$) AS INTEGER
DECLARE FUNCTION VFindExe(pFName$, pFExten$, pDest$) AS INTEGER
DECLARE FUNCTION VIsSystemAdequate AS INTEGER
'----------------------------------------------------------------
'- Purpose:
'- to have cheap quicky way to message boxes
'- Arguments:
'- the text message and the dialog title
'- Returns:
'- nothing
'----------------------------------------------------------------
SUB VMessageBox(msg$, title$) STATIC
i% = DoMsgBox(msg$, title$, MB_ICONEXCLAMATION+MB_OK)
END SUB
'----------------------------------------------------------------
'- Purpose:
'- to do quicky debug messages
'- Arguments:
'- the text message and the dialog title
'- Returns:
'- nothing
'----------------------------------------------------------------
SUB VDbgMsgBox(msg$, title$) STATIC
'$IFDEF DEBUG
VMessageBox msg$, title$
'$ENDIF 'DEBUG
END SUB
'----------------------------------------------------------------
'- Purpose:
'- Appends a file name to the end of a directory path,
'- inserting a backslash character if needed.
'- Arguments:
'- szDir$ - full directory path (with optional ending "\")
'- szFile$ - filename to append to directory
'- Returns:
'- Resulting fully qualified path name.
'----------------------------------------------------------------
FUNCTION VMakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
VMakePath = szFile$
ELSEIF szFile$ = "" THEN
VMakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
VMakePath = szDir$ + szFile$
ELSE
VMakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
'----------------------------------------------------------------
'----------------------------------------------------------------
'' From the MS Knowledge Base CD #2:
''following were taken from windows.h. &H means they're hex
CONST WS_VISIBLE=&H10000000
CONST WS_BORDER =&H00800000
CONST WS_CLIPCHILDREN =&H02000000
CONST GWL_STYLE =-16
CONST SW_SHOWMAXIMIZED=3
DECLARE FUNCTION ShowWindow LIB "user.exe" (hWnd%,iShow%) AS INTEGER
DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
SUB VMaximizeFrame STATIC
hWnd%=HwndFrame()
i&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
j%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
END SUB
'----------------------------------------------------------------
'----------------------------------------------------------------
FUNCTION VFindExeFromRegistration (pFExten$, pDest$) STATIC AS INTEGER
'' set the local vars.
lDestDir$ = ""
lDrive$ = ""
CursorSave% = ShowWaitCursor()
'' step one: try to find the file in the win.ini extensions section.
IF pFExten$ <> "" THEN
lDrive$ = GetIniKeyString("WIN.INI", "Extensions", pFExten$)
VDbgMsgBox "Extension entry from Win.ini: " + lDrive$, "VRDEBUG"
IF lDrive$ <> "" THEN ''there is a key
''remove the tail (^.VVR)
StrLen% = LEN(lDrive$)
WHILE (MID$(lDrive$, StrLen%, 1) <> "^") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
TNAME$ = MID$(lDrive$, 1, StrLen%)
lDrive$ = RTRIM$(TNAME$)
VDbgMsgBox "After stripping the file type: " + lDrive$, "VRDEBUG"
StrLen% = DoesFileExist(lDrive$, femExists) '' file still there?
IF StrLen% = 0 THEN
'' we didn't find it. But it could be in the path, in which case
'' the entry might just be the file name. We should check for this
'' case (however, we must extract the exe name from any path first,
'' since otherwise FindTargetOnEnvVar will fail nastily.
'' Extract file name from directory name. Find if this is a path
PathLen% = LEN(lDrive$)
WHILE (PathLen% > 0) AND(MID$(lDrive$, PathLen%, 1) <> "\")
PathLen% = PathLen% - 1
WEND
'' If Pathlen% = 0, lDrive$ is a filename and we should search the
'' path environment variable. If PathLen% > 0, lDrive$ is an invalid
'' path and we should punt.
IF PathLen% = 0 THEN
tempStr$ = FindTargetOnEnvVar(lDrive$, "PATH")
IF tempStr$ <> "" THEN
StrLen% = DoesFileExist(tempStr$, femExists)
IF StrLen% = 1 THEN '' file exists
lDrive$ = tempStr$
VDbgMsgBox "Found EXE through PATH$ at: " + lDrive$, "VRDEBUG"
END IF
END IF
END IF
END IF
IF StrLen% = 1 THEN '' file still there!
StrLen% = LEN(lDrive$)
'' Extract directory name
WHILE (MID$(lDrive$, StrLen%, 1) <> "\") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
lDestDir$ = MID$(lDrive$, 1, StrLen%)
VDbgMsgBox "Dir name: " + lDestDir$, "lDestDir"
'' Directory okay?
i% = DoesDirExist(lDestDir$)
IF i% = 0 THEN
lDrive$ = ""
lDestDir$ = ""
END IF
ELSE '' no key. Poop.
lDrive$ = ""
lDestDir$ = ""
END IF
ENDIF
'$IFDEF DEBUG
ELSE
VMessageBox "No file extension passed to VFindExe", "VFindExe Debug"
'$ENDIF 'DEBUG
ENDIF
'' can't find it; punt!
IF lDestDir$ = "" THEN
VDbgMsgBox "Can't find exe anywhere", "VFindExeFromRegistration Debug"
pDest$ = ""
VFindExeFromRegistration = 0
ELSE
pDest$ = lDestDir$
VFindExeFromRegistration = 1
ENDIF
RestoreCursor CursorSave%
END FUNCTION
'----------------------------------------------------------------
'----------------------------------------------------------------
FUNCTION VFindExe (pFName$, pFExten$, pDest$) STATIC AS INTEGER
'$ifdef DEBUG
if pFName$ = "" then
BadArgErr 1, "VFindExe", pFName$
end if
'$endif ''DEBUG
'' set the local vars.
lDestDir$ = ""
lDrive$ = ""
'' step one: try to find the file in the win.ini extensions section.
found% = VFindExeFromRegistration (pFExten, lDestDir$)
'' step two: search the hard drive for the exe.
IF lDestDir$ = "" THEN
dLetter$ = ""
LDList$ = "LocalHardDriveList"
VDbgMsgBox "Can't find exe from win.ini", "VFindExe Debug"
OldCursor% = ShowWaitCursor() '' set waiting cursor
sz$ = UIStartDlg("mscuistf.dll", LOOKFORFILE_DLG, "FModelessDlgProc", 0, "")
GetLocalHardDrivesList LDList$
DListLength% = GetListLength(LDList$)
FOR i% = 1 TO DListLength% STEP 1
dLetter$ = GetListItem(LDList$, i%)
IF (dLetter$ <> "" AND lDestDir$ = "") THEN
lDrive$ = dLetter$ + ":\"
lDestDir$ = FindFileInTree(pFName$, lDrive$)
ENDIF
NEXT i%
VDbgMsgBox "found an exe in " + lDestDir$, "VFindExe"
IF lDestDir$ <> "" THEN
lDrive$ = lDestDir$
StrLen% = LEN(lDrive$)
'' Extract directory name
WHILE (MID$(lDrive$, StrLen%, 1) <> "\") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
lDestDir$ = MID$(lDrive$, 1, StrLen%)
END IF
UIPop 1
RestoreCursor OldCursor%
END IF
'' step three: punt!
IF lDestDir$ = "" THEN
VDbgMsgBox "Can't find exe anywhere", "VFindExe Debug"
pDest$ = ""
VFindExe = 0
ELSE
pDest$ = lDestDir$
VFindExe = 1
ENDIF
END FUNCTION
'----------------------------------------------------------------
'- Purpose:
'- to check if the user's system can handle our stuff.
'- (Win 3.1 on a 386 or better)
'- Arguments:
'- none.
'- Returns:
'- TRUE/FALSE if system is up to our